import '@babel/polyfill';
import '../css/index.css';
import '../css/voucher.css';
import '../css/return.css';

// 返回按钮
let returnbtn = document.querySelector(".return");
returnbtn.addEventListener("click",function () {
    if (sessionStorage.getItem("token")) {
        window.location.href = "./select.html";
    }else{
        alert("error!!!")
    }
})

let _name = document.querySelector(".name_div");
let box_header = document.querySelector(".box_header");
let headline = document.querySelector(".headline");
let day_time = document.querySelector(".headline>p");
let _img = document.querySelector(".ewmBox>img");
let save = document.querySelector(".save");
 
_img.src = `${sessionStorage.getItem("img")}`;
_name = `${sessionStorage.getItem("_name")}`;
day_time = sessionStorage.getItem("day_time");
let cc_time = sessionStorage.getItem("cc_time");
// console.log(sessionStorage.getItem("img"));
// console.log(_img.src);
// console.log(sessionStorage.getItem("_name"));

headline.innerHTML = 
`<p>欢迎您在${day_time}/${cc_time}参观2019广州国际花卉艺术展暨中国插花花艺展。</p>`
box_header.innerHTML = 
`<div class="name_div" style="text-align: center">${_name}</div>`

save.addEventListener("click", function () {
    download(_img.src, "预约二维码");
})
function download(url, name) {
    const aLink = document.createElement('a')
    aLink.download = name
    aLink.href = url
    aLink.dispatchEvent(new MouseEvent('click', {}))
}